package com.khalil.kkadmin.module.ai.model;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class AiModelManagerImpl implements AiModelManager {

    private final AiModelRepository repository;

    public AiModelManagerImpl(AiModelRepository repository) {
        this.repository = repository;
    }


    @Override
    public AiModel create(AiModel aiModel) {
        return repository.save(aiModel);
    }

    @Override
    public AiModel update(AiModel aiModel) {
        return repository.save(aiModel);
    }

    @Override
    public void delete(Long id) {
        repository.deleteById(id);
    }

    @Override
    public AiModel get(Long id) {
        Optional<AiModel> optionalAiModel = repository.findById(id);
        return optionalAiModel.orElse(null);
    }

    @Override
    public List<AiModel> list(ListQuery listQuery) {
        return repository.findAll();
    }
}
